﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="TeamBuildTray.MainBuildList"
    Title="Team Build Tray" Height="400" Width="700" AllowsTransparency="True" ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" WindowState="Normal" Background="{x:Null}" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Name="window" xmlns:TeamBuildTray="clr-namespace:TeamBuildTray" Icon="Green.ico" WindowStyle="None" MinWidth="600" MinHeight="300">

    <Window.Resources>
        <TeamBuildTray:BuildStatusConverter x:Key="BuildStatusConverter"/>
        <TeamBuildTray:BuildVisibilityConverter x:Key="BuildVisibilityConverter"/>
        <DataTemplate x:Key="BuildContentTemplate">
            <ItemsControl ItemsSource="{Binding}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
					    <Border Width="Auto" Height="Auto" BorderBrush="{x:Null}" BorderThickness="0,0,0,0" CornerRadius="0,0,0,0" Margin="2,0,2,0" Background="{x:Null}" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave" >
					    	<Border.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Queue build" Click="BorderMenuForceBuild_Click" Tag="{Binding Path=.}" />
						</ContextMenu>
					    	</Border.ContextMenu>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="25" />
                                <ColumnDefinition Width="*" />
								<ColumnDefinition Width="125" />
                            </Grid.ColumnDefinitions>
                                <Image Source="{Binding Path=Status, Converter={StaticResource BuildStatusConverter}}" Width="16" Height="16"/>
                            <Label Grid.Column="1" Margin="0,-1,0,0" HorizontalAlignment="Stretch">
	                            <TextBlock Text="{Binding Path=BuildNumber}" TextWrapping="Wrap" Foreground="#FFFFFFFF" />
                            </Label>
                            <Label Grid.Column="2" Margin="0,-1,0,0" HorizontalAlignment="Left">
	                            <TextBlock Text="{Binding Path=RequestedFor}" TextWrapping="Wrap" Foreground="#FFFFFFFF" />
                            </Label>
                        </Grid>
						</Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>
        <DataTemplate x:Key="BuildContentTemplateConfigure">
            <ItemsControl ItemsSource="{Binding}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
					    <Border Width="Auto" Height="Auto" BorderBrush="{x:Null}" BorderThickness="0,0,0,0" CornerRadius="0,0,0,0" Margin="2,0,2,0" Background="{x:Null}" MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave" >
					    	<Border.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Queue build" Click="BorderMenuForceBuild_Click" Tag="{Binding Path=.}" />
						</ContextMenu>
					    	</Border.ContextMenu>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="25" />
                                <ColumnDefinition Width="*" />
								<ColumnDefinition Width="125" />
								<ColumnDefinition Width="25" />
                            </Grid.ColumnDefinitions>
                                <Image Source="{Binding Path=Status, Converter={StaticResource BuildStatusConverter}}" Width="16" Height="16"/>
                            <Label Grid.Column="1" Margin="0,-1,0,0" HorizontalAlignment="Stretch">
	                            <TextBlock Text="{Binding Path=BuildNumber}" TextWrapping="Wrap" Foreground="#FFFFFFFF" />
                            </Label>
                            <Label Grid.Column="2" Margin="0,-1,0,0" HorizontalAlignment="Left">
	                            <TextBlock Text="{Binding Path=RequestedFor}" TextWrapping="Wrap" Foreground="#FFFFFFFF" />
                            </Label>
                            <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" Content="" Grid.Column="3" Tag="{Binding Path=.}" IsChecked="{Binding Path=BuildDefinitionUri, Converter={StaticResource BuildVisibilityConverter}, Mode=OneWay}" Checked="CheckBox_CheckChanged" Unchecked="CheckBox_CheckChanged"/>
                        </Grid>
						</Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </DataTemplate>

        <Style x:Key="ButtonClose" BasedOn="{x:Null}" TargetType="{x:Type Button}">
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type Button}">
        				<Grid>
        					<Image Source="BlueX.png" Stretch="Fill"/>
        					<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
        				</Grid>
        				<ControlTemplate.Triggers>
        					<Trigger Property="IsFocused" Value="True"/>
        					<Trigger Property="IsDefaulted" Value="True"/>
        					<Trigger Property="IsMouseOver" Value="True"/>
        					<Trigger Property="IsPressed" Value="True"/>
        					<Trigger Property="IsEnabled" Value="False"/>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
        <Style x:Key="ButtonSearch" BasedOn="{x:Null}" TargetType="{x:Type Button}">
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type Button}">
        				<Grid>
        					<Image Source="search.png" Stretch="Fill"/>
        					<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True"/>
        				</Grid>
        				<ControlTemplate.Triggers>
        					<Trigger Property="IsFocused" Value="True"/>
        					<Trigger Property="IsDefaulted" Value="True"/>
        					<Trigger Property="IsMouseOver" Value="True"/>
        					<Trigger Property="IsPressed" Value="True"/>
        					<Trigger Property="IsEnabled" Value="False"/>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
    </Window.Resources>

    <Border Width="Auto" Height="Auto" BorderBrush="{x:Null}" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5" MouseDown="Border_MouseDown" Background="{DynamicResource BrushMainGradient}">
        <Grid>
        	<Grid.RowDefinitions>
        		<RowDefinition Height="22.946"/>
        		<RowDefinition Height="*"/>
        	</Grid.RowDefinitions>
            <TeamBuildTray:NotifyIcon Width="192" Height="71" x:Name="NotifyIconMainIcon" MouseDoubleClick="NotifyIconMainIcon_MouseDoubleClick" HorizontalAlignment="Right" Margin="0,0,-215,-86.5" VerticalAlignment="Bottom" Grid.Row="1">
                <TeamBuildTray:NotifyIcon.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Open" Click="NotifyIconOpen_Click" />
                        <MenuItem Header="Show last notification" Click="NotifyIconOpenNotifications_Click" />
                        <Separator/>
                        <MenuItem Header="Exit" Click="NotifyIconExit_Click" />
                    </ContextMenu>
                </TeamBuildTray:NotifyIcon.ContextMenu>
            </TeamBuildTray:NotifyIcon>
            <ScrollViewer VerticalScrollBarVisibility="Auto" Content="{Binding Path=BuildContent, ElementName=window, Mode=Default}" ContentTemplate="{DynamicResource BuildContentTemplate}" d:UseSampleData="True" Margin="0,4,2,15" Grid.RowSpan="2" Grid.Row="1" x:Name="ScrollViewerBuildList"/>
            <Border HorizontalAlignment="Stretch" Background="#28000000" CornerRadius="5,5,5,5">
            	<Grid>
            		<Grid.ColumnDefinitions>
            			<ColumnDefinition Width="*"/>
            			<ColumnDefinition Width="37.076"/>
            			<ColumnDefinition Width="33.095"/>
            		</Grid.ColumnDefinitions>
            		<Button Style="{DynamicResource ButtonClose}" Width="15" Content="" HorizontalAlignment="Center" Click="Button_Click" Cursor="Hand" Height="15" Grid.Column="2" VerticalAlignment="Center" Name="ButtonClose" />
            		<Label HorizontalAlignment="Left" Content="Jobs-o-matic Team Build Tray" FontSize="12" FontStyle="Normal" FontWeight="Bold" Foreground="#FFFFFFFF" Padding="0,0,0,0" x:Name="LabelMainTitle" VerticalAlignment="Center" Margin="10,0,0,0"/>
            		<Button Style="{DynamicResource ButtonSearch}" Grid.Column="1" Click="ButtonSearch_Click" Width="15" Height="15" Cursor="Hand" Name="ButtonConfigure" />
            	</Grid>
            </Border>
        </Grid>
    </Border>
</Window>
